﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SwapValuesOfSpecificBits_13
{
    class Program
    {
        static uint[] binaryConverter(uint number)
        {
            uint[] binaryArray = new uint[32];
            for (int index = 0; index < 32; index++)
            {
                binaryArray[index] = number % 2;
                number /= 2;
            }
            Array.Reverse(binaryArray);
            return binaryArray;
        }
        static void swap(ref uint first, ref uint second)
        {
            uint swapValue = second;
            second = first;
            first = swapValue;
        }
        static void Main(string[] args)
        {
            uint number = 310;
            int p = 4;
            int k = 5;
            int q = 20;

            uint[] a = binaryConverter(number);
            foreach (var item in a)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();
            for (int i = a.Length - (p + 1); i > a.Length -( p + 1 + k); i--)
            {
                swap(ref a[i], ref a[32 - q++]);
            }
            foreach (var item in a)
            {
                Console.Write(item + " ");
            }

        }
    }
}
